import React, { Component } from 'react';
import {NavLink, Route, Routes} from 'react-router-dom'
import Detail from './Detail';

class Message extends Component {

  state = {
    messageArr: [
      {id: '01', title: '消息1', content: 'hello1'},
      {id: '02', title: '消息2', content: 'hello2'},
      {id: '03', title: '消息3', content: 'hello3'}
    ]
  }
  render() {
    const {messageArr} = this.state
    return (
      <div>
          <ul>
           {
            messageArr.map ((msgObj) => {
              return (
                <li key={msgObj.id}>
                <NavLink to='/home/message/detail'>{msgObj.title}</NavLink>&nbsp;&nbsp;
              </li>
              )
            })
           }
          </ul>
          <hr />
          <Routes>
          <Route path='/detail' element={<Detail />} />
          </Routes>
        </div>
    );
  }
}

export default Message;
